package com.ssy.lingxi.order.model.vo.common.response;

import com.ssy.lingxi.common.constant.order.OrderTypeEnum;
import com.ssy.lingxi.order.utils.NumberUtil;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 售后能力 - 退货换货 - 查询订单商品
 * @author 万宁
 * @version 2.0.0
 * @date 2021-08-04
 */
public class OrderAfterSaleProductDetailVO implements Serializable {
    private static final long serialVersionUID = -2975506613066526558L;

    public OrderAfterSaleProductDetailVO(Long productId, Integer orderType, String processKey, Long skuId, String productNo, String logo, String name, String category, String brand, String unit, String spec, BigDecimal quantity, BigDecimal price, BigDecimal amount, BigDecimal paidAmount, BigDecimal exchangeCount, BigDecimal returnCount, BigDecimal maintainCount, BigDecimal returnAmount, Boolean tax, BigDecimal taxRate, Integer priceType, Long quotedSkuId, String quotedProductNo, String quotedName, String quotedCategory, String quotedBrand, String quotedSpec) {
        this.productId = productId;
        this.skuId = NumberUtil.isNullOrNegative(skuId) ? 0L : skuId;
        this.processKey = StringUtils.hasLength(processKey) ? processKey : "";
        if(orderType.equals(OrderTypeEnum.QUERY_PRICE_CONTRACT.getCode()) || orderType.equals(OrderTypeEnum.PRICE_COMPETITION_CONTRACT_PURCHASE.getCode()) || orderType.equals(OrderTypeEnum.PURCHASE_CONTRACT_BIDDING.getCode()) || orderType.equals(OrderTypeEnum.REQUISITION_TO_PURCHASE.getCode())) {
            this.productNo = productNo;
        } else {
            this.productNo = String.valueOf(skuId);
        }

        this.logo = StringUtils.hasLength(logo) ? logo : "";
        this.name = name;
        this.category = category;
        this.brand = brand;
        this.spec = StringUtils.hasLength(spec) ? spec : "";
        this.unit = unit;
        this.quantity = NumberUtil.formatToInteger(quantity);
        this.price = NumberUtil.formatAmount(price);
        this.amount = NumberUtil.formatAmount(amount);
        this.paidAmount = NumberUtil.formatAmount(paidAmount);
        this.exchangeCount = NumberUtil.formatToInteger(exchangeCount);
        this.returnCount = NumberUtil.formatToInteger(returnCount);
        this.maintainCount = NumberUtil.formatToInteger(maintainCount);
        this.returnAmount = NumberUtil.formatAmount(returnAmount);
        this.tax = tax;
        this.taxRate = NumberUtil.formatAmount(taxRate.multiply(BigDecimal.valueOf(100)));
        this.priceType = priceType;
        this.quotedProductNo = NumberUtil.notNullOrZero(quotedSkuId) ? String.valueOf(quotedSkuId) : (StringUtils.hasLength(quotedProductNo) ? quotedProductNo : "");
        this.quotedName = StringUtils.hasLength(quotedName) ? quotedName : "";
        this.quotedCategory = StringUtils.hasLength(quotedCategory) ? quotedCategory : "";
        this.quotedBrand = StringUtils.hasLength(quotedBrand) ? quotedBrand : "";
        this.quotedSpec = StringUtils.hasLength(quotedSpec) ? quotedSpec : "";
    }

    /**
     * 商品Id
     */
    private Long productId;

    /**
     * 商品SkuId
     */
    private Long skuId;

    /**
     * 工作流的ProcessKey
     */
    private String processKey;

    /**
     * 商品物料编号
     */
    private String productNo;

    /**
     * 商品logo
     */
    private String logo;

    /**
     * 商品名称
     */
    private String name;

    /**
     * 品类
     */
    private String category;

    /**
     * 品牌
     */
    private String brand;

    /**
     * 规格
     */
    private String spec;

    /**
     * 单位
     */
    private String unit;

    /**
     * 采购数量
     */
    private String quantity;

    /**
     * 单价
     */
    private String price;

    /**
     * 金额
     */
    private String amount;

    /**
     * 已支付的金额
     */
    private String paidAmount;

    /**
     * 是否含税
     */
    private Boolean tax;

    /**
     * 税率（百分比的分子部分，例如税率是0.8，返回80）
     */
    private String taxRate;

    /**
     * 商品类型，定义在商品服务的 PriceTypeEnum 中
     */
    private Integer priceType;

    /**
     * 已换货数量
     */
    private String exchangeCount;

    /**
     * 已退货数量
     */
    private String returnCount;

    /**
     * 维修数量
     */
    private String maintainCount;

    /**
     * 退款金额
     */
    private String returnAmount;

    /**
     * 关联报价商品的编号或SkuId
     */
    private String quotedProductNo;

    /**
     * 关联报价商品名称
     */
    private String quotedName;

    /**
     * 关联报价商品规格
     */
    private String quotedSpec;

    /**
     * 关联报价商品品类
     */
    private String quotedCategory;

    /**
     * 关联报价商品品牌
     */
    private String quotedBrand;

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Long getSkuId() {
        return skuId;
    }

    public void setSkuId(Long skuId) {
        this.skuId = skuId;
    }

    public String getProcessKey() {
        return processKey;
    }

    public void setProcessKey(String processKey) {
        this.processKey = processKey;
    }

    public String getProductNo() {
        return productNo;
    }

    public void setProductNo(String productNo) {
        this.productNo = productNo;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getSpec() {
        return spec;
    }

    public void setSpec(String spec) {
        this.spec = spec;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getQuantity() {
        return quantity;
    }

    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public String getPaidAmount() {
        return paidAmount;
    }

    public void setPaidAmount(String paidAmount) {
        this.paidAmount = paidAmount;
    }

    public Boolean getTax() {
        return tax;
    }

    public void setTax(Boolean tax) {
        this.tax = tax;
    }

    public String getTaxRate() {
        return taxRate;
    }

    public void setTaxRate(String taxRate) {
        this.taxRate = taxRate;
    }

    public Integer getPriceType() {
        return priceType;
    }

    public void setPriceType(Integer priceType) {
        this.priceType = priceType;
    }

    public String getExchangeCount() {
        return exchangeCount;
    }

    public void setExchangeCount(String exchangeCount) {
        this.exchangeCount = exchangeCount;
    }

    public String getReturnCount() {
        return returnCount;
    }

    public void setReturnCount(String returnCount) {
        this.returnCount = returnCount;
    }

    public String getMaintainCount() {
        return maintainCount;
    }

    public void setMaintainCount(String maintainCount) {
        this.maintainCount = maintainCount;
    }

    public String getReturnAmount() {
        return returnAmount;
    }

    public void setReturnAmount(String returnAmount) {
        this.returnAmount = returnAmount;
    }

    public String getQuotedProductNo() {
        return quotedProductNo;
    }

    public void setQuotedProductNo(String quotedProductNo) {
        this.quotedProductNo = quotedProductNo;
    }

    public String getQuotedName() {
        return quotedName;
    }

    public void setQuotedName(String quotedName) {
        this.quotedName = quotedName;
    }

    public String getQuotedSpec() {
        return quotedSpec;
    }

    public void setQuotedSpec(String quotedSpec) {
        this.quotedSpec = quotedSpec;
    }

    public String getQuotedCategory() {
        return quotedCategory;
    }

    public void setQuotedCategory(String quotedCategory) {
        this.quotedCategory = quotedCategory;
    }

    public String getQuotedBrand() {
        return quotedBrand;
    }

    public void setQuotedBrand(String quotedBrand) {
        this.quotedBrand = quotedBrand;
    }
}
